class Solution {
public:
    int search(vector<int>& a, int x) {
        int l = -1, r = a.size();
        while (l + 1 < r) {
            int mid = l + r >> 1;
            cout << "mid==" << mid << endl;
            if (a[mid] >= x)r = mid;
            else l = mid;
        }
        if (r <= a.size() - 1) {
            if (a[r] == x)return r;
        }
        return -1;
    }
};